package com.example.food.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.food.adapter.StoreclassiAdapter;
import com.example.food.bean.StoreclassiBean;
import com.example.home.R;
import com.example.home.tool.OKHttpTool;

public class StoreclassiDetailActivity extends AppCompatActivity {
    private ImageView img;
    private TextView title;
    private SearchView search;
    private RecyclerView rcv_list;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_storeclassi_detail);
        Intent intent = getIntent();
        String storeId = intent.getStringExtra("StoreId");
        initView();
        getList(storeId);
    }



    private void getList(String storeId) {
        OKHttpTool.doNetRequest("prod-api/api/takeout/seller/list?themeId="+storeId,
                OKHttpTool.GET,
                StoreclassiBean.class,
                new OKHttpTool.NetCallback() {
                    @Override
                    public void onSuccess(Object obj) {
                        StoreclassiBean storeclassiBean = (StoreclassiBean) obj;
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                rcv_list.setAdapter(new StoreclassiAdapter(StoreclassiDetailActivity.this,storeclassiBean.getRows()));
                                rcv_list.setLayoutManager(new LinearLayoutManager(StoreclassiDetailActivity.this));
                            }
                        });
                    }
                    @Override
                    public void onFailure(String msg) {

                    }
                });
    }

    private void initView() {


        img = findViewById(R.id.img);
        title = findViewById(R.id.title);
        search = findViewById(R.id.search);
        rcv_list = findViewById(R.id.rcv_list);

    }
}